package com.dotstone.chipism.adapter;

import java.util.List;

import com.dotstone.chipism.R;
import com.dotstone.chipism.bean.Home;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class HouseAdapper extends BaseAdapter {

	private Context context;
	private List<Home> data;

	public HouseAdapper(Context context) {
		this.context = context;
	}

	public HouseAdapper(Context context, List<Home> data) {
		this.data = data;
		this.context = context;
	}


	public void setData(List<Home> data) {
		this.data = data;
	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View view, ViewGroup parent) {
		if (view == null) {
			view = LayoutInflater.from(context).inflate(R.layout.item_house, null);
			holdView = new HoldView();
			holdView.houseTv = (TextView) view.findViewById(R.id.name_tv);
			view.setTag(holdView);
		} else {
			holdView = (HoldView) view.getTag();
		}
		Home h = data.get(position);
		holdView.houseTv.setText(h.getHomeName());

		return view;
	}

	HoldView holdView;

	class HoldView {
		private TextView houseTv;
	}


}
